﻿using MediatR;
using NLog;
using S.EarTag.API.Application.MediatorCommand.EarTagCommand;
using S.EarTag.Domain.ApiResult;
using S.EarTag.Domain.Dto;
using S.EarTag.Domain.Model;
using S.EarTag.Infrastructure.Repository.Interface.IEarTagRepository;

namespace S.EarTag.API.Application.MediatorCommandHandler.EarTagCommandHandler
{
    public class EarTagGetEarTagCommandHandler : IRequestHandler<EarTagGetEarTagCommand, List<EarTagModelDto>>
    {
        private readonly IEarTagModelRepository _earTagModelRepository;
        private readonly ILogger<EarTagGetEarTagCommandHandler> _logger;
        public EarTagGetEarTagCommandHandler(IEarTagModelRepository earTagModelRepository,ILogger<EarTagGetEarTagCommandHandler> logger)
        {
            _earTagModelRepository = earTagModelRepository;
            _logger = logger;
        }
        /// <summary>
        /// 查询全部状态为false的可视耳号
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<List<EarTagModelDto>> Handle(EarTagGetEarTagCommand request, CancellationToken cancellationToken)
        {
            var list= await _earTagModelRepository.GetEarTagModels();
            return list;
            //ApiResult<List<EarTagModelDto>> Apiresult = new ApiResult<List<EarTagModelDto>>();
            //Apiresult.Data = list;
            ////总条数总页数
            //Apiresult.totalCount = list.Count();
            //Apiresult.pageCount = (int)Math.Ceiling((Apiresult.totalCount * 1.0) / request.pageSize);
            ////分页功能
            //Apiresult.Data=list.Skip((request.pageIndex-1)*request.pageSize).Take(request.pageSize).ToList();
            //return Apiresult;
        }
    }
}
